#if !defined(AFX_METHODTHREADPOOL_H__7B586027_767C_45B2_8294_B0BDDEE9CF22__INCLUDED_)
#define AFX_METHODTHREADPOOL_H__7B586027_767C_45B2_8294_B0BDDEE9CF22__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MethodThreadPool.h : header file
//

#define WM_APP_METHODTHREADEXITED   (WM_APP+100)
#define WM_APP_EXITTHREAD           (WM_APP+102)

class MethodThread;
class BaseMethodPerformer;

/////////////////////////////////////////////////////////////////////////////
// CMethodThreadPool thread

class CMethodThreadPool : public CWinThread
{
	DECLARE_DYNCREATE(CMethodThreadPool)
protected:
	CMethodThreadPool();           // protected constructor used by dynamic creation

// Attributes
private:
  static CMethodThreadPool * m_pInstance;

  std::list<MethodThread *> m_MethodThreads;

  CMutex m_mutexMethodThreads;

// Operations
public:
  static CMethodThreadPool * Instance();
  static void DeleteInstance();
  void AddMethod(BaseMethodPerformer * pPerformer);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMethodThreadPool)
	public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CMethodThreadPool();

	// Generated message map functions
	//{{AFX_MSG(CMethodThreadPool)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
  afx_msg LRESULT OnMethodThreadExited(WPARAM wParam, LPARAM lParam);
  afx_msg LRESULT OnExitThread(WPARAM wParam, LPARAM lParam);

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_METHODTHREADPOOL_H__7B586027_767C_45B2_8294_B0BDDEE9CF22__INCLUDED_)
